var teamId;
var teamName;
var tmGameId;
var placeId;
var tmTeamPlace;
$(document).ready(function(){ 
	$('#header').animate({'top':'0px'},400);
	teamId = args.teamId; //取得id的值
	teamName = args.teamName;
	tmGameId = args.tmGameId;
	placeId = args.placeId;
	var param = {placeId:placeId};
	$.getJSON(path+"/soccer/teamGameAction!getTeamPlace.action",param, function(data){
		  tmTeamPlace = data.tmTeamPlace;
		  txtfixlatitude.value=tmTeamPlace.placeLatitude;
		  txtfixlongitude.value=tmTeamPlace.placeLongitude;
	},'json');
	
	getLocation();
	
	setInterval("displayDistance()",3000);
	
	$("#kqBtn").click(function(){
		var strMessage;
		var successFlag="0";
		getDistance();
		var curDistance = parseInt(txtDistance.value);
		if(curDistance<=200){
			successFlag="1";
			strMessage="签到成功，离球场距离"+curDistance+"米";
		}else if(curDistance>200&&curDistance<=1000){
			successFlag="0";
			strMessage="签到失败，离球场距离"+curDistance+"米";
		}else if(curDistance>1000){
			strMessage="签到失败！尼玛，你是在岛国签到吧。";
		}else{
			strMessage="签到失败！计算距离错误。";
		}
		var postData={teamId:teamId,tmGameId:tmGameId,successFlag:successFlag,remark:strMessage};
		$.post(path+"/soccer/teamGameAction!gameKq.action",postData, function(data){
			strMessage = data.strMessage;
			$('#strMessage').text(strMessage);
		},'json');
	});
});
function displayDistance(){
	var distanceMessage;
	getDistance();
	distanceMessage="当前位置("+txtcurlongitude.value+","+txtcurlatitude.value+")离球场距离"+txtDistance.value+"米！";
	$('#distanceMessage').text(distanceMessage);
}
function goBack(){
	window.location.href=path+"/soccer/teamGame.jsp?teamId="+teamId+"&teamName="+teamName;
}
